package com.yowasa.xiuxian.engine.hone.special;

import com.yowasa.xiuxian.annoations.SE;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.engine.hone.SpecialInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.bo.user.UserBattle;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;

@SE(name = "五德之身")
public class WuDeZhiShen implements SpecialInterface {
    @Override
    public ElementEnum getElement() {
        return ElementEnum.GOLD;
    }

    @Override
    public void limit(UserBO user) {
        String lingGenDesc = ElementEnum.getLingGenDesc(user.getElement(), XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY);
        if (lingGenDesc.length() != 2) {
            throw new HandlerException("学习/使用五德之身必须为双灵根");
        }
    }

    @Override
    public String limitDesc() {
        return "只拥有二种灵根";
    }

    @Override
    public String desc() {
        return "修习之后依据拥有的灵根获取不同的属性 金:提高20%的攻击力 木:提高20%的血量上限 水:提高20%的速度和免疫 火:提高20%的术法 土:提高20%的双防";
    }

    @Override
    public void effectBattle(UserBO userBO, UserBattle userBattle) {
        String lingGenDesc = ElementEnum.getLingGenDesc(userBO.getElement(), XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY);
        if (lingGenDesc.contains("金")) {
            userBattle.setAtk((int) (userBattle.getAtk() +userBO.getUserOriginBattle().getAtk() * 0.2));
        }
        if (lingGenDesc.contains("木")) {
            userBattle.setHp((int) (userBattle.getHp() + userBO.getUserOriginBattle().getHp() * 0.2));
        }
        if (lingGenDesc.contains("水")) {
            userBattle.setImm((int) (userBattle.getImm() + userBO.getUserOriginBattle().getImm() * 0.2));
            userBattle.setSpd((int) (userBattle.getSpd() + userBO.getUserOriginBattle().getSpd() * 0.2));
        }
        if (lingGenDesc.contains("火")) {
            userBattle.setSpell((int) (userBattle.getSpell() + userBO.getUserOriginBattle().getSpell() * 0.2));
        }
        if (lingGenDesc.contains("土")) {
            userBattle.setDef((int) (userBattle.getDef() + userBO.getUserOriginBattle().getDef() * 0.2));
            userBattle.setRes((int) (userBattle.getRes() + userBO.getUserOriginBattle().getRes() * 0.2));
        }
    }
}
